const helper = require("./helper");

module.exports = async function (req, res) {
  console.log("*****************收到push*****************");
  console.log(req.body);

  if (!req.body.commits || req.body.commits.length == 0) {
    return { msg: "message is null" };
  }
  let commitMsg, password;
  commitMsg = req.body.commits[0].message.replace("\n", "").replace(" ", "");
  password = req.body.repository.name;
  let obj = helper.valite(commitMsg, password);
  if (obj.msg != "ok") {
    return res.json(obj);
  }
  helper.doAction(obj, res);
};
